import { _decorator, Component, Node, Sprite, SpriteFrame } from 'cc';
import { BUYTYPE, ITEMTYPE } from '../../Game/GameConstant';
const { ccclass, property } = _decorator;

@ccclass('SpriteSwitch')
export class SpriteSwitch extends Component {

    @property({ type: Sprite })
    Sprite: Sprite = null;

    @property({ type: SpriteFrame })
    NormalSF: SpriteFrame = null;

    @property({ type: SpriteFrame })
    CanelSF: SpriteFrame = null;

    isMute: boolean = false;
    isPitch: boolean = false;

    /**
     * 声音跟震动样式的切换
     */
    switch() {
        this.isMute = !this.isMute;
        if (this.isMute) {
            this.Sprite.spriteFrame = this.CanelSF;
        } else {
            this.Sprite.spriteFrame = this.NormalSF;
        }
    }

    /**
     * 按钮的样式的切换
     */
    switchStyle() {
        this.isPitch = !this.isPitch;
        if (this.isPitch) {
            this.Sprite.spriteFrame = this.NormalSF;
        } else {
            this.Sprite.spriteFrame = this.CanelSF;
        }
    }

    /**
     * 解锁按钮样式
     */
    switchUnluckStyle(type: BUYTYPE) {
        if (BUYTYPE.GOLD == type) {
            this.Sprite.spriteFrame = this.NormalSF;
        } else if (BUYTYPE.VIDEO == type) {
            this.Sprite.spriteFrame = this.CanelSF;
        }
    }
}


